using System;
using System.Web;
using Model;

    public class BaseLogin
    {
        public static string SessionLoginName="sysUser";
        public BaseLogin()
        {
        }

        public static SessionUser getSessionNode(HttpContext context)
        {
            if (context.Session[SessionLoginName] == null)
            {
                return null;
            }
            return (Model.SessionUser)context.Session[SessionLoginName];
        }
        public static int getUserID(HttpContext context)
        {
            if (context.Session[SessionLoginName] == null)
            {
                return 0;
            }
            return ((Model.SessionUser)context.Session[SessionLoginName]).uid;
        }
        public static string getUserName(HttpContext context)
        {
            if (context.Session[SessionLoginName] == null)
            {
                return "";
            }
            return ((Model.SessionUser)context.Session[SessionLoginName]).userName;
        }
        public static bool isHaveLogin(HttpContext context)
        {
            try
            {
                if (context.Session[SessionLoginName] == null)
                {
                    return false;
                }
            }
            catch {
                return false;
            }
            return true;
        }
        public static void ClearSession(HttpContext context)
        {
            context.Session.Clear();
        }
        public static void SetSession(HttpContext context, SessionUser info)
        {
            context.Session[SessionLoginName] = info;
        }
        public static void Logout(HttpContext context)
        {
            context.Session.Clear();
            context.Session.Abandon();
        }
       
    }
